package com.token.iot.bratterycharging.gateway.business;

import java.util.Map;

import org.springframework.stereotype.Component;

import com.outstanding.framework.core.Logger;
import com.outstanding.framework.core.PendingException;
import com.outstanding.framework.log.LoggerFactory;
import com.token.iot.bratterycharging.gateway.AbstractSender;
import com.token.iot.bratterycharging.gateway.ChannelHandlerContextManager;
import com.token.iot.bratterycharging.gateway.IDGeneration;
import com.token.iot.bratterycharging.gateway.Semaphore;
import com.token.iot.bratterycharging.gateway.SemaphoreManager;
import com.token.iot.bratterycharging.gateway.Sender;
import com.token.iot.bratterycharging.gateway.sender.ASYSender;
import com.token.iot.bratterycharging.gateway.utils.ByteUtil;

import io.netty.channel.ChannelHandlerContext;



/**
 * 删除重传队列
 * 
 * @author chenzhixuan
 *
 */
@Component("DLBSender")
public class DLBSender extends AbstractSender {

	private static ChannelHandlerContextManager manager = new ChannelHandlerContextManager();

	private static Logger loger = LoggerFactory.getLogger(DLBSender.class);

	@Override
	public Object send(String imei, Map<String, String> params) throws PendingException {
		loger.info("Staring The  DLBSender ");
		// 查找对应的HandlerContext
		ChannelHandlerContext context = manager.getChannelHandlerContextByImei(imei);
		String sessionid = IDGeneration.createSeesionID();
		String num = params.get("NO");
		String command = code + sessionid + "/"+num;
		byte[] c = ByteUtil.addFlag(command.getBytes());
		loger.info("the send =" + new String(c));
		context.writeAndFlush(c);
		return null;
	}




}
